<!--
 * @Descripttion: 订单进度
 * @version:
 * @Author: lehaixia
 * @Date: 2022-10-28 13:18:09
 * @LastEditors: lehaixia
 * @LastEditTime: 2022-12-23 16:31:46
-->
<template>
  <div class="">
    <ComHeader title="订单进度" bg-color="F8F8FA" @get-height="handleHeadHeight" />
    <Progress :dict-data="dictData" :active="active" />
  </div>
</template>
<script>
import Progress from '@/components/Progress'
import { getDictByPatchType } from '@/apis/dataDict'
import { getOrderStageLine } from '@/apis/purOrder'

export default {
  name: 'OrderProgressDetail',
  components: { Progress },
  props: {},
  data() {
    return {
      active: 0,
      headHeight: 50,
      dictData: []
    }
  },
  computed: {},
  watch: {},
  async created() {
    const { id, state } = this.$route.query
    const list = await getOrderStageLine({ orderId: id })
    const dictTypeCodes = ['CRM_PURCHASE_ORDER_STATUS']
    const dictData = await getDictByPatchType({ dictTypeCodes })
    this.dictData = dictData.CRM_PURCHASE_ORDER_STATUS
    this.dictData.forEach((v, i) => {
      list.forEach((m, ii) => {
        if (v.dictCode === m.stage) {
          // const time = m.handleDate
          const desc = ',将订单流转到' + v.dictName
          if (i > 0) {
            this.dictData[i - 1].time = list[ii - 1].handleDate
            this.dictData[i - 1].desc = list[ii - 1].handlerStaff + desc
          }
        }
      })
    })

    const active = this.dictData.findIndex(v => v.dictCode === state)
    if (active !== -1) {
      this.active = active
    }
  },
  // 方法集合
  methods: {
    handleHeadHeight(h) {
      this.headHeight = h
    }
  }
}
</script>
<style lang='less' scoped>

</style>
